home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- /*
- * to2bpp - Create a file with 2 byte-per-pixel encoding.
- *
- * Created 4/1/93 by Tim Heidmann to get around apparent getrow() bug.
- */
- #include <gl/image.h>
-
- short rowbuf[8192];
-
- main(argc,argv)
- int argc;
- char **argv;
- {
- register IMAGE *iimage, *oimage;
- register int x, y, z;
- int xsize, ysize, zsize;
- short mask;
-
- if( argc!=3 ) {
- fprintf(stderr,"usage: to2bpp inimage outimage\n");
- exit(1);
- }
- if( (iimage=iopen(argv[1],"r")) == NULL ) {
- fprintf(stderr,"mult: can't open input file %s\n",argv[1]);
- exit(1);
- }
- oimage = iopen(argv[2],"w",
- (iimage->type & TYPEMASK) | BPP(2),
- iimage->dim, iimage->xsize, iimage->ysize, iimage->zsize);
- isetname(oimage,iimage->name);
- oimage->colormap = iimage->colormap;
- mask = (iimage->type & BPPMASK) == 1 ? 0x00ff : 0x0000;
- for(z=0; z<iimage->zsize; z++)
- for(y=0; y<iimage->ysize; y++) {
- getrow(iimage,rowbuf,y,z);
- for (x = 0; x < iimage->xsize; x++) rowbuf[x] &= mask;
- putrow(oimage,rowbuf,y,z);
- }
- iclose(iimage);
- iclose(oimage);
- exit(0);
- }
-